#parse('/subject/final/edit/menu_include.html')
<h3>课题研究人员信息</h3>
<a data-url="/subject/$!subjectId/final/edit/personnel/add" onclick="openPage(this)">添加</a>
<table data-subject_id="$!subjectId">
    <tr>
        <th>姓名</th>
        <th>单位</th>
        <th>年龄</th>
        <th>职务/职称</th>
        <th>学历/学位</th>
        <th>课题所承担工作</th>
        <th>操作</th>
    </tr>
    #foreach($personnel in $personnels)
    <tr data-id="$!finalPersonnel.id">
        <td>$!personnel.name</td>
        <td>$!personnel.unit</td>
        <td>$!personnel.age</td>
        <td>$!personnel.position</td>
        <td>$!personnel.education</td>
        <td>$!personnel.task</td>
        <td>
            <a data-url="/subject/$subjectId/final/edit/personnel/$!personnel.id/update" onclick="openPage(this)">修改</a>
            <a onclick="subjectFinalPersonnalDelete(this)">删除</a>
        </td>
    </tr>
    #end
</table>
<input type="button" value="返回" data-url="/subject/final/list/host" onclick="openPage(this)">
<input type="button" value="上一步" data-url="/subject/$!subjectId/final/edit/main" onclick="openPage(this)">
<input type="button" value="下一步" data-url="/subject/$!subjectId/final/edit/achievement" onclick="openPage(this)">
<script type="text/javascript">
    function subjectFinalPersonnalDelete(item) {
        if (confirm("您确定提交吗？提交后将不能再修改！")) {
            var tr = $(item).closest("tr");
            $.ajax({
                url: "/api/subject/final/personnel/delete",
                type: "post",
                data: "subject_id=" + tr.closest("table").data("subject_id") + "&id=" + tr.data("id"),
                dataType: "json",
                cache: false,
                beforeSend: function() {
                },
                complete: function() {
                },
                success: function (result) {
                    if (result.code == 200) {
                        tr.remove();
                    } else {
                        alert(result.msg);
                    }
                },error: function (result) {
                    alert("网络连接出错！");
                }
            });
        }
    }
</script>